package com.example.kugou.service.serviceimpl;

import com.example.kugou.mapper.PersonalDataMapper;
import com.example.kugou.pojo.Personal_data;
import com.example.kugou.service.Personal_dataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.Map;

@Service("personal_dataService")
public class Personal_dataServiceImpl implements Personal_dataService {

    @Resource
    PersonalDataMapper personal_dataMapper;

    public PersonalDataMapper getPersonal_dataMapper() {
        return personal_dataMapper;
    }

    public void setPersonal_dataMapper(PersonalDataMapper personal_dataMapper) {
        this.personal_dataMapper = personal_dataMapper;
    }

    @Override
    public Map<String, Object> YanZhengPhone(String phone) {
        Map<String,Object> map=new LinkedHashMap<>();
        map.put("state","Failed");
        Personal_data personal_data = personal_dataMapper.YanZhengPhone(phone);
        if (personal_data!=null){
            map.put("state","Success");
            map.put("person",personal_data);
        }
        return map;
    }

    @Override
    public Map<String, Object> ZhuCe(Personal_data personal_data) {
        Map<String,Object> map=new LinkedHashMap<>();
        map.put("state","Failed");
        int i = personal_dataMapper.ZhuCe(personal_data);
        if (i >0 ){
            map.put("state","Success");
        }
        return map;
    }

    @Override
    public Map<String, Object> loginByAccountAndPassword(String account, String password) {
        Map<String,Object> map=new LinkedHashMap<>();
        map.put("state","Failed");
        Personal_data personal_data = personal_dataMapper.loginByAccountAndPassword(account, password);
        if (personal_data!=null){
            map.put("state","Success");
            map.put("person",personal_data);
        }
        return map;
    }

    @Override
    public  Map<String,Object> updatePerson_Data(Personal_data personal_data) {
        Map<String,Object> map=new LinkedHashMap<>();
        int i = personal_dataMapper.updatePerson_Data(personal_data);
        map.put("state","Failed");
        if (i>0){
            map.put("state","Success");
        }
        return map;
    }

    @Override
    public Map<String, Object> queryPersonById(int pid) {
        Map<String,Object> map=new LinkedHashMap<>();
        map.put("state","Failed");
        Personal_data personal_data = personal_dataMapper.queryPersonById(pid);
        if (personal_data!=null){
            map.put("state","Success");
            map.put("person",personal_data);
        }
        return map;
    }
}
